package hasTohas

import (
	"context"
	"errors"
	v1 "gf-example/api/relationalQuery/v1"
	"gf-example/internal/dao"
	"gf-example/internal/service"
)

type sHasToHas struct {
}

func New() *sHasToHas {

	return &sHasToHas{}
}
func init() {
	service.RegisterHasToHas(New())
}

// FindByHasToHas 一对一查询
func (s *sHasToHas) FindByHasToHas(ctx context.Context) (out *v1.HasToHasRes, errs error) {
	out = &v1.HasToHasRes{Content: &v1.HasToHas{}}
	err := dao.Boyfriend.Ctx(ctx).
		Where(dao.Boyfriend.Columns().BoyfriendId, 2).
		WithAll().
		Scan(&out.Content)
	if err != nil {
		return nil, errors.New("查询数据库出错:" + err.Error())
	}
	return out, nil
}
